﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TrainDetail.aspx.cs" Inherits="news_mini_TrainDetail" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>新增/修改培训信息</title>

<link href="../../css/style.css" rel="stylesheet" type="text/css" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript" defer="defer" src="../../My97DatePicker/WdatePicker.js"></script>

<base target="_self"/>
</head>
<body>
    <form id="form2" runat="server">
    <div class="button_bar">
          <asp:Button ID="btnBack" CssClass="common_button" runat="server" Text="返回" 
              onclick="btnBack_Click" ValidationGroup="22" />
        <%--<asp:Button ID="btnSave" CssClass="common_button" runat="server" Text="保存" OnClick="btnSave_Click" />--%>
        <input type="submit" id="submit" value="保存" class="common_button" />
    </div>
    <div>
    <input id="trid" type="hidden"  value="<%=trid %>" />
    <table class="query_form_table">        
      <tr>
            <th>
                主题
            <span style="color:Red">*</span></th>
            <td colspan="3">
                <input type="text" id="title" name="title" maxlength="180"  style="width:500px;"  value="<%=title %>" />
            </td>            
        </tr>
	    <tr>            
            <th>开始时间</th>
            <td><input id="begin" name="begin" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" type="text"   value="<%=begin %>" /></td> 
            <th>结束时间</th>
            <td><input id="end" name="end" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" type="text"   value="<%=end %>" /></td>        
        </tr>                
        <tr>
            <th>
                讲师
           </th>
           <td>
              <input type="text" id="lecture" name="lecture" maxlength="18" style="width:150px;"  value="<%=lec %>" />
           </td>
            <th>限制人数</th>
            <td >
                <input type="text" id="percount" name="percount" maxlength="3" style="width:150px;"  value="<%=percount %>" />
              
            </td> 
                    
        </tr>
        <tr>
        <th>密码</th>
           <td>
                <input type="text" id="pw" name="pw" maxlength="100" style="width:500px;"  value="<%=pw %>" />
           </td>          
           <th>网址</th>
           <td >
               <input type="text" id="address" name="address" maxlength="398" style="width:500px;"  value="<%=add %>" />
           </td>                 
       
    </table>
    </div>
   
    </form>

    <script type="text/javascript" language="javascript">


        $("#submit").click(function () {
            var frm = $('form1');
            var title = $('#title');
            var begin = $('#begin');
            var end = $('#end');
            var lec = $('#lecture');
            var percount = $('#percount');
            var add = $('#address');
            var content = $('#pw');

            if ($.trim(title.val()) == '') {
                alert('请输入培训主题');
                title.focus();
                return false;
            }

            if ($.trim(begin.val()) == '') {
                alert('请选择开始时间');
                begin.focus();
                return false;
            }
            if ($.trim(end.val()) == '') {
                alert('请选择结束时间');
                end.focus();
                return false;
            }
            if ($.trim(lec.val()) == '') {
                alert('请输入培训讲师');
                lec.focus();
                return false;
            }
            if ($.trim(percount.val()) == '') {
                alert('请输入限制人数');
                percount.focus();
                return false;
            }
            else {
                var reg = /^[1-9]\d*$/;
                if (!reg.test(percount.val())) {
                    alert("‘限制人数’只允许输入正整数");
                    percount.focus();
                    return false;
                }

            }
            if ($.trim(add.val()) == '') {
                alert('请输入网址');
                add.focus();
                return false;
            }
            else {
                var reg = /^(http|https):\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
                if (!reg.test(add.val())) {
                    alert("请输入标准网址,如：http://www.emoney.cn");
                    add.focus();
                    return false;
                }
            }

            if ($.trim(content.val()) == '') {
                alert('请输入密码');
                content.focus();
                return false;
            }

            if ($('#trid').val() == "") {
                $.post("ManageHandler.ashx",
                             { T: "add", trid: "", title: title.val(), begin: begin.val(), end: end.val(), lecture: lec.val(), address: add.val(), content: content.val(), type: "ZXHC", percount: percount.val() },
                             function (data, textStatus) {
                                 if (textStatus == "success") {
                                     alert("保存成功！");
                                     window.open("TrainManage.aspx", "_self");
                                 }
                                 else
                                     alert("error");
                             });
            }
            else {
                $.post("ManageHandler.ashx",
                             { T: "modify", trid: $('#trid').val(), title: title.val(), begin: begin.val(), end: end.val(), lecture: lec.val(), address: add.val(), content: content.val(), type: "ZXHC", percount: percount.val() },
                              function (data, textStatus) {
                                  if (textStatus == "success") {
                                      alert("保存成功！");
                                      window.open("TrainManage.aspx", "_self");
                                  }
                                  else
                                      alert("error");
                              });
            }

        });

        
      
    </script>
</body>
</html>